#include<bits/stdc++.h>
using namespace std;
bool a[10001][1001];
int find_maxl(int n, int i){
	int maxl = -1;
	int tmp = 0;
	for(int j = 0; j < n; j++){
		if(a[i][j] == 1){
			tmp ++;
			maxl = tmp > maxl ? tmp : maxl;
		}else{
			tmp = 0;
		}
	}
	return maxl;
}
int main(){
	memset(a,0,sizeof(a[0]));
	int n;
	cin >> n;
	int max_h = -1;
	for(int i = 0; i < n; i++){
		int tmp;
		cin >> tmp;
		max_h = tmp > max_h ? tmp : max_h;
		for(int j = 0; j < tmp; j++){
			a[j][i] = 1;
		}
	}
	int max_l = -1;
	int max_s = -1;
	for(int i = 0; i <= max_h; i++){
		max_l = find_maxl(n,i);
		int tmp_s = max_l * (i + 1);
		max_s = tmp_s > max_s ? tmp_s : max_s;
	}
	cout << max_s << endl;
	return 0;
}
